<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/7/8
 * Time: 21:46
 */

namespace App\Http\Controllers;

//use App\Models\Hotel;
//use App\Facades\CharFacade;
use charFacade;//app.php加了别名后使用
use App\Models\Access;
use App\Models\RoleAccess;
use App\Models\Roles;
//use App\Util\CharUtil;
use DB;
use Illuminate\Http\Request;

class IndexController extends Controller
{

    public function charTest()
    {
        //传统方式：new CharUtil();
        //IOC方式,解耦，分手大师
        //IOC管理，放在一起，容器

        //查看是否注册成功 (打印所有经过$this->app->singleton方法操作之后的结果，即打印所有绑定的服务)
        //dd(app()->getBindings());

        //调用
        //app('char') 获取类的实例
        //return app('char')->index();//==(new \App\Util\CharUtil)->idnex()

        //用门面调用
        return charFacade::index();


    }
    
    public function add(Request $request)
    {
        return $request->all();
    }
    
    public function index()
    {
        /*$result = DB::table('hotel')->first();
        echo json_encode($result);*/

        //echo "<pre>";
        /*$res  = Hotel::get()->where('id', 6738)->toArray();
        echo json_encode($res);*/

        //$res2  = RoleAccess::get()->where('ra_roleId', 1)->toArray();

        //$res  = Roles::find(1)->getAccess;
        //$res  = Roles::with('accessIds')->get()->where('role_id', 1)->toArray();

        //$res = Access::get()->toArray();

        /*$res  = Roles::with(['accessIds' => function ($query){
               $query->with('accessInfo');
            }])->get()->where('role_id', 1)->toArray();
        echo "<pre>";
        print_r($res);*/

        //echo json_encode($res);
        
        return view('index');

    }
}